package animator.phantom.renderer.plugin;

import animator.phantom.plugin.*;
import animator.phantom.renderer.param.*;
import animator.phantom.paramedit.*;
import com.jhlabs.image.SparkleFilter;
import java.awt.image.*;
import java.awt.geom.*;
import java.awt.*;
import java.util.*;

public class SparklePlugin extends PhantomPlugin
{
	public ColorParam color = new ColorParam( new Color(255,255,255) );
	public IntegerParam randomness = new IntegerParam( 50, 0,100);
	public IntegerParam amount = new IntegerParam( 50,0,100 );
	public IntegerParam rays = new IntegerParam( 50, 0, 300 );
	public IntegerParam radius = new IntegerParam( 25, 0, 300 );
	public IntegerParam seed = new IntegerParam( 42 );

	public SparklePlugin()
	{
		initPlugin( STATIC_SOURCE );
	}

	public void buildDataModel()
	{
		setName( "Sparkle" );
		registerParameter( color );
		registerParameter( randomness );
		registerParameter( amount );
		registerParameter( rays );
		registerParameter( radius );
 		//registerParameter( seed );
	}

	public void buildEditPanel()
	{
		ParamColorSelect colorE = new ParamColorSelect( color, "Color");
		IntegerValueSliderEditor randomnessE  = new IntegerValueSliderEditor( "Randomness" , randomness );
		IntegerValueSliderEditor amountE = new IntegerValueSliderEditor( "Amount" , amount );
		IntegerValueSliderEditor raysE = new IntegerValueSliderEditor( "Rays" , rays );
		IntegerValueSliderEditor radiusE = new IntegerValueSliderEditor( "Radius" , radius );
		//IntegerNumberEditor seedE = new IntegerNumberEditor( "Seed", seed );

		addEditor( colorE );
		addRowSeparator();
		addEditor( randomnessE );
		addRowSeparator();
		addEditor( amountE );
		addRowSeparator();
		addEditor( raysE );
		addRowSeparator();
		addEditor( radiusE );
		//addRowSeparator();
		//addEditor( seedE );
	}

	public void doImageRendering( int frame )
	{
		BufferedImage img = PluginUtils.createScreenCanvas();

		SparkleFilter filter = new SparkleFilter();
		filter.setColor( color.get().getRGB() );
		filter.setRandomness( randomness.get() );
		filter.setAmount( amount.get() );
		filter.setRays( rays.get() );
		filter.setRadius( radius.get() );
		//filter.setSeed( seed.get() );
	
		PluginUtils.filterImage( img, filter );

		sendStaticSource( img, frame );
	}

}//end class
